<?php
/**
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */

namespace App\Admin\Export;

use App\UserWithdraw;
use Encore\Admin\Grid\Exporters\AbstractExporter;
use Maatwebsite\Excel\Facades\Excel;

class UserWithdrawExport extends AbstractExporter
{
    public function export()
    {
      //  dd($this->getData());
        Excel::create('User presentation', function($excel) {
            $excel->sheet('User presentation', function($sheet) {
                $rows1=collect([['申请人','银行卡号','银行卡类型','状态','提现金额','申请时间']]);
                // 这段逻辑是从表格数据中取出需要导出的字段
                $rows = collect($this->getData())->map(function ($item) {
                    return [
                       $item['user_name'],
                        (string)$item['bank_code'].' ',
                       isset(UserWithdraw::$bankMap[$item['bank_type']]) ? UserWithdraw::$bankMap[$item['bank_type']] : $item['bank_type'],
                        UserWithdraw::$statusMap[$item['status']],
                       $item['price'],
                       $item['created_at']
                    ];
                });
                $sheet->rows($rows1);
                $sheet->rows($rows);

            });

        })->export('xls');

    }
}